using System;
using System.Collections.Generic;
using System.Text;

namespace XiaoGang.Soft.XGWMS.DAL_SQL
{
    public class DAL_M008_STOREROOM_SQL
    {
        #region SQL

        #region INIT_COMBOX_SQL

        private static string _init_COMBOX_SQL = @"
            SELECT   [USER_ID]
                    ,[USER_NAME]
            FROM     [M003_USER]
            WHERE    TRANS_STATE <> '3' AND TRANS_STATE <> '9'
			ORDER BY [USER_ID]";

        #endregion

        #region GET_SINGLE_DATA_SQL
        private static string _get_Single_Data_SQL = @"
            SELECT    [STOREROOM_ID]
                     ,[STOREROOM_NM]
                     ,[STOREROOM_ADDRESS]
                     ,[STOREROOM_PHONE]
                     ,[STOREROOM_MANAGER]
                     ,[STOREROOM_STATE]
                     ,[MEMO]
            FROM [M008_STOREROOM]
            WHERE STOREROOM_ID = @STOREROOM_ID";
        #endregion

        #region CHECK_NAME_SQL
        private static string _check_Nmae_SQL = @"SELECT  [STOREROOM_ID]
                     ,[STOREROOM_NM]                     
            FROM [M008_STOREROOM]
            WHERE 1=1 ";
        #endregion

        #region STORAGEROOM_DELETE_CHECK_SQL
        private static string _storageroom_Delete_Check_SQL = @"SELECT	DISTINCT STOREROOM_ID
              FROM	M009_STORAGE
             WHERE	STOREROOM_ID = @STOREROOM_ID";
        #endregion

        #region INSERT_STOREROOM_SQL

        private static string _insert_STOREROOM_SQL = @" 
            INSERT INTO [M008_STOREROOM]
               ([CREATE_DATETIME]
               ,[UPDATE_DATETIME]
               ,[TRANS_STATE]
               ,[UPDATER_ID]
               ,[TERMINAL_CD]
               ,[STOREROOM_ID]
               ,[STOREROOM_NM]
               ,[STOREROOM_ADDRESS]
               ,[STOREROOM_PHONE]
               ,[STOREROOM_MANAGER]
               ,[STOREROOM_STATE]
               ,[MEMO]
            )VALUES(
                CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
               ,CONVERT(VARCHAR,GETDATE(),112)+REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
               ,'1'
               ,@UPDATER_ID
               ,@TERMINAL_CD
               ,@STOREROOM_ID
               ,@STOREROOM_NM
               ,@STOREROOM_ADDRESS
               ,@STOREROOM_PHONE
               ,@STOREROOM_MANAGER
               ,@STOREROOM_STATE
               ,@MEMO)";

        #endregion

        #region UPDATE_STOREROOM_SQL

        private static string _update_STOREROOM_SQL = @"UPDATE [M008_STOREROOM]
               SET [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')               
                  ,[TRANS_STATE] = '2'
                  ,[UPDATER_ID] = @UPDATER_ID
                  ,[TERMINAL_CD] = @TERMINAL_CD
                  ,[STOREROOM_ID] = @STOREROOM_ID
                  ,[STOREROOM_NM] = @STOREROOM_NM
                  ,[STOREROOM_ADDRESS] = @STOREROOM_ADDRESS
                  ,[STOREROOM_PHONE] = @STOREROOM_PHONE
                  ,[STOREROOM_MANAGER] = @STOREROOM_MANAGER
                  ,[STOREROOM_STATE] = @STOREROOM_STATE
                  ,[MEMO] = @MEMO
            WHERE  STOREROOM_ID = @STOREROOM_ID";

        #endregion

        #region LOGIC_DELETE_STOREROOM_SQL

        private const string _logic_Delete_STOREROOM_SQL = @"
           UPDATE [M008_STOREROOM]
           SET    [UPDATE_DATETIME] = CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
                 ,[TRANS_STATE] = @TRANS_STATE
                 ,[UPDATER_ID] = @UPDATER_ID
                 ,[TERMINAL_CD] = @TERMINAL_CD
           WHERE STOREROOM_ID = @STOREROOM_ID
           AND   TRANS_STATE <> '3'";

        #endregion

        #region PHYSICAL_DELETE_STOREROOM_SQL

        private const string _physical_Delete_STOREROOM_SQL = @"DELETE FROM [M008_STOREROOM]  WHERE  STOREROOM_ID = @STOREROOM_ID";

        #endregion

        #endregion 

        #region Proprety

        public static string Init_Combox_SQL
        {
            get
            {
                return _init_COMBOX_SQL;
            }
        }

        public static string Get_Single_Data_SQL
        {
            get
            {
                return _get_Single_Data_SQL;
            }
        }

        public static string Check_Name_SQL
        {
            get
            {
                return _check_Nmae_SQL;
            }
        }

        public static string StorageRoom_Delete_Check
        {
            get
            {
                return _storageroom_Delete_Check_SQL;
            }
        }

        public static string Insert_STOREROOM_SQL
        {
            get
            {
                return _insert_STOREROOM_SQL;
            }
        }
        
        public static string Update_STOREROOM_SQL
        {
            get
            {
                return _update_STOREROOM_SQL;
            }
        }

        public static string Logic_Delete_STOREROOM_SQL
        {
            get
            {
                return _logic_Delete_STOREROOM_SQL;
            }
        }

        public static string Physical_Delete_STOREROOM_SQL
        {
            get
            {
                return _physical_Delete_STOREROOM_SQL;
            }
        }

        #endregion
    }
}
